/**
 * Copyright JS Foundation and other contributors, http://js.foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 **/

.red-ui-tabs {
    position: relative;
    background: var(--red-ui-tab-background);
    overflow: hidden;
    height: 35px;
    box-sizing: border-box;

    .hide-tab {
        transition: width 0.1s ease-in;
    }
    .red-ui-tabs-scroll-container {
        height: 60px;
        overflow-x: scroll;
        overflow-y: hidden;
        &::-webkit-scrollbar {
            display: none;
        }
    }
    & ul {
        list-style-type: none;
        padding:0;
        margin: 0;
        display: block;
        height: 35px;
        box-sizing:border-box;
        border-bottom: 1px solid var(--red-ui-primary-border-color);
        white-space: nowrap;
        @include disable-selection;

        li {
            box-sizing: border-box;
            display: inline-block;
            border-left: 1px solid  var(--red-ui-primary-border-color);
            border-top: 1px solid  var(--red-ui-primary-border-color);
            border-right: 1px solid var(--red-ui-primary-border-color);
            border-bottom: 1px solid var(--red-ui-primary-border-color);
            background: var(--red-ui-tab-background-inactive);
            margin: 3px 3px 0 3px;
            height: 32px;
            line-height: 29px;
            max-width: 200px;
            width: 14%;
            overflow: hidden;
            white-space: nowrap;
            position: relative;
            &.red-ui-tabs-closeable:hover {
                .red-ui-tabs-badges {
                    display: none;
                }
                .red-ui-tab-close {
                    display: block;
                }
            }
            a.red-ui-tab-label {
                display: block;
                font-size: 14px;
                padding-left: 12px;
                width: 100%;
                height: 100%;
                color: var(--red-ui-tab-text-color-inactive);
            }
            a:hover {
                text-decoration: none;
            }
            a:focus {
                text-decoration: none;
            }

            &:not(.active) a:hover+a.red-ui-tab-close {
                background: var(--red-ui-tab-background-hover);
            }
            &.highlighted {
                box-shadow: 0px 0px 4px 2px var(--red-ui-node-selected-color);
                border: dashed 1px var(--red-ui-node-selected-color);
            }
            &.active {
                background: var(--red-ui-tab-background-active);
                font-weight: bold;
                border-bottom: 1px solid var(--red-ui-tab-background-active);
                z-index: 2;

                a {
                    color: var(--red-ui-tab-text-color-active);
                }
                a.red-ui-tab-close {
                    color: var(--red-ui-workspace-button-color);
                    background: var(--red-ui-tab-background-active);
                    &:hover {
                        background: var(--red-ui-workspace-button-background-hover) !important;
                        color: var(--red-ui-workspace-button-color-hover);
                    }
                }
                img.red-ui-tab-icon {
                    opacity: 0.2;
                }

                .red-ui-tabs-fade {
                    background-image: linear-gradient(to right, var(--red-ui-tab-background-active-alpha), var(--red-ui-tab-background-active));
                }

            }
            &.selected {
                &:not(.active) {
                    background: var(--red-ui-tab-background-selected);
                    .red-ui-tabs-fade {
                        background-image: linear-gradient(to right, var(--red-ui-tab-background-selected-alpha), var(--red-ui-tab-background-selected));
                    }
                    .red-ui-tabs-badge-selected {
                        background: var(--red-ui-tab-background-selected);
                    }
                }
                font-weight: bold;
                .red-ui-tabs-badge-selected {
                    display: inline;
                    background: var(--red-ui-tab-background);
                }
                .red-ui-tabs-badge-changed {
                    display: none;
                }

            }
            &:not(.active) a:hover {
                color: var(--red-ui-workspace-button-color-hover);
                background: var(--red-ui-tab-background-hover);
                &+.red-ui-tabs-fade {
                    background-image: linear-gradient(to right, var(--red-ui-tab-background-hover-alpha), var(--red-ui-tab-background-hover));
                }
            }
        }
    }
    &.red-ui-tabs-scrollable {
        padding-left: 21px;
        padding-right: 21px;
    }
    &.red-ui-tabs-add {
        padding-right: 29px;
    }
    &.red-ui-tabs-add.red-ui-tabs-scrollable {
        padding-right: 53px;
    }
    &.red-ui-tabs-add.red-ui-tabs-menu.red-ui-tabs-scrollable,
    &.red-ui-tabs-add.red-ui-tabs-search.red-ui-tabs-scrollable {
        padding-right: 83px;
    }

    &.red-ui-tabs-add.red-ui-tabs-search.red-ui-tabs-menu.red-ui-tabs-scrollable {
        padding-right: 113px;
    }

    &.red-ui-tabs-collapsible {
        li:not(.active) {
            display: none;
             &.red-ui-tab-pinned {
                 a {
                     padding-left: 0;
                     text-align: center;
                 }
                 span {
                     display: none;
                 }
                 width: 32px;
             }
        }
    }

    &.red-ui-tabs-vertical {
        box-sizing: border-box;
        height: 100%;
        border-right: 1px solid var(--red-ui-primary-border-color);
        margin: 0;
        background: var(--red-ui-tertiary-background);
        overflow: visible;

        .red-ui-tabs-scroll-container {
            height: auto;
            overflow-x:visible;
            overflow-y: scroll;
        }

        & ul {
            padding: 0;
            height: auto;
            border: none;
            width: calc(100% + 1px);
            li {
                width: 100%;
                display: block;
                margin: 0;
                border: none;
                border-right: 1px solid var(--red-ui-primary-border-color);
                height: auto;
                &:not(:first-child) {
                    border-top: 1px solid var(--red-ui-secondary-border-color);
                }
                &:last-child {
                    border-bottom: 1px solid var(--red-ui-secondary-border-color);
                }

                a.red-ui-tab-label {
                    padding: 9px;
                }

                &.active {
                    border-right: 1px solid var(--red-ui-tab-background-active);
                }
            }
        }
    }
    .red-ui-tabs-select {
        position: absolute;
        top:0;
        bottom: 0;
        left: 0;
        right: 0;
        opacity: 0.4;
        background: red;
    }
}
.red-ui-tab-button {
    position: absolute;
    box-sizing: border-box;
    top: 0;
    right: 0;
    height: 35px;
    background: var(--red-ui-tab-background);
    border-bottom: 1px solid var(--red-ui-primary-border-color);
    z-index: 2;

    a {
        @include workspace-button;
        line-height: 30px;
        height: 28px;
        width: 28px;
        margin-left: 2px;
        margin-right: 2px;
        margin-top: 3px;
        margin-bottom: 3px;
        border: none;
        z-index: 2;
    }
}
.red-ui-tab-link-buttons {
    position: absolute;
    box-sizing: border-box;
    top: 0;
    right: 0;
    height: 35px;
    background: var(--red-ui-tab-background);
    border-bottom: 1px solid var(--red-ui-primary-border-color);
    z-index: 2;
    a {
        @include workspace-button-toggle;
        line-height: 26px;
        height: 28px;
        width: 28px;
        margin: 4px 3px 3px;
        z-index: 2;
        &.red-ui-tab-link-button-menu {
            border-color: var(--red-ui-tab-background);
        }
        &:not(.single):not(.selected) {
            margin-top: 4px;
        }
    }
}
.red-ui-tab-scroll {
    width: 21px;
    top: 0;
    a {
        height: 35px;
        width: 21px;
        display: block;
        color: var(--red-ui-workspace-button-color);
        font-size: 22px;
        text-align: center;
        margin:0;
        border-left: none;
        border-right: none;
        border-top: none;
        border-bottom: 1px solid var(--red-ui-primary-border-color);
        line-height: 34px;
    }
}
.red-ui-tab-scroll-left {
    left:0;
    a {
        border-right: 1px solid var(--red-ui-primary-border-color);
    }
}
.red-ui-tab-scroll-right {
    right: 0px;
    a {
        border-left: 1px solid var(--red-ui-primary-border-color);
    }

}
.red-ui-tabs.red-ui-tabs-add .red-ui-tab-scroll-right {
    right: 32px;
}

.red-ui-tabs.red-ui-tabs-add.red-ui-tabs-menu .red-ui-tab-scroll-right,
.red-ui-tabs.red-ui-tabs-add.red-ui-tabs-search .red-ui-tab-scroll-right {
    right: 64px;
}
.red-ui-tabs.red-ui-tabs-add.red-ui-tabs-menu .red-ui-tabs-add,
.red-ui-tabs.red-ui-tabs-add.red-ui-tabs-search .red-ui-tabs-add {
    right: 32px;
}

.red-ui-tabs.red-ui-tabs-add.red-ui-tabs-search.red-ui-tabs-menu {
    .red-ui-tab-scroll-right {
        right: 96px;
    }
    .red-ui-tabs-add {
        right: 64px;
    }
    .red-ui-tabs-search {
        right: 32px;
    }
}

.red-ui-tabs-fade {
    position: absolute;
    bottom: 0;
    top: 0;
    right: 0;
    width: 15px;
    background-image: linear-gradient(to right, var(--red-ui-tab-background-inactive-alpha), var(--red-ui-tab-background-inactive));
    pointer-events: none;
}


i.red-ui-tab-icon {
    opacity: 0.7;
    width: 18px;
    height: 20px;
    &:not(.fa) {
        display: inline-block;
        margin-left: -8px;
        margin-right: 3px;
        margin-top: -2px;
        opacity: 1;
        width: 20px;
        height: 20px;
        vertical-align: middle;
        -webkit-mask-size: contain;
        mask-size: contain;
        -webkit-mask-position: center;
        mask-position: center;
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        background-color: var(--red-ui-tab-icon-color);
    }
}
.red-ui-tabs-badges {
    position: absolute;
    top:0px;
    right:0px;
    width: 20px;
    pointer-events: none;
    display: block;
    height: 30px;
    line-height: 28px;
    text-align: center;
    padding:0px;
    color: var(--red-ui-tab-badge-color);
}

.red-ui-tabs-badges i {
    display: none;
}

.red-ui-tab.node_changed img.node_changed {
    display: inline-block;
}
.red-ui-tab.node_error img.node_error {
    display: inline-block;
}

.red-ui-tabs-badges img {
    width: 10px;
    height: 10px;
    margin-right: 2px;
    vertical-align: top;

}
.red-ui-tab-hide {
    .fa-eye-slash {
        display: none;
    }
    &:hover {
        .fa-eye-slash {
            display: inline
        }
        .fa-eye {
            display: none
        }
    }
}
.red-ui-tab-close {
    display: none;
    background: var(--red-ui-tab-background-inactive);
    opacity: 0.8;
    position: absolute;
    right: 0px;
    top: 0px;
    width: 20px;
    height: 30px;
    line-height: 28px;
    text-align: center;
    padding: 0px;
    color: var(--red-ui-workspace-button-color);
    &:hover {
        background: var(--red-ui-workspace-button-background-hover) !important;
        color: var(--red-ui-workspace-button-color-hover);
        opacity: 1;
    }
}
